// 云函数入口文件
const cloud = require('wx-server-sdk')

cloud.init()

// 云函数入口函数
exports.main = async (event, context) => {
  const wxContext = cloud.getWXContext()
  const openid = wxContext.OPENID // 获取用户的openid
  const roleid = event.roleid
  var role = ''
  if(openid === roleid){
    role = '管理员'
  }else{
    role = '用户'
  }
  return {
    role,
    openid: openid,
    nickname:wxContext.nickname,
    avatarUrl:wxContext.avatarUrl
  }
}